from flask import Flask, jsonify, redirect
from flask_cors import CORS
import os
from os import system

app = Flask(__name__)
CORS(app, supports_credentials=True)#配置跨域请求

@app.route('/sleep', methods=['GET', 'POST'])
def sleep():
    system("powercfg -h off")
    system("rundll32.exe powrprof.dll,SetSuspendState 0,1,0")
    result = {
        "msg": True,
    }
    return jsonify(result)

@app.route('/shutdown', methods=['GET', 'POST'])
def shutdown():
    system("powercfg -h on")
    system("rundll32.exe powrprof.dll,SetSuspendState 0,1,0")
    result = {
        "msg": True,
    }
    return jsonify(result)

@app.route('/control', methods=['GET', 'POST'])
def control():
    system("control")
    result = {
        "msg": True,
    }
    return jsonify(result)

@app.route('/uninstall', methods=['GET', 'POST'])
def uninstall():
    system("appwiz.cpl ")
    result = {
        "msg": True,
    }
    return jsonify(result)

@app.route('/tgp', methods=['GET', 'POST'])
def tgp():
    system("start H:\WeGame\wegame.exe")
    result = {
        "msg": True,
    }
    return jsonify(result)

@app.route('/bili', methods=['GET', 'POST'])
def bili():
    system("explorer http://bilibili.com")
    result = {
        "msg": True,
    }
    return jsonify(result)

if __name__ == "__main__":
    app.run('0.0.0.0', debug=True, port=250) 









